sales <- read_csv("sales.csv") %>% 
  mutate(net = price - cost - shipping) %>% 
  filter(region == params$region) %>% 
  filter_by_time(date, params$startdate, params$enddate)

Sales Summary - EMEA

This report summarizes sales of our 3 products in the EMEA region between 2019-01-01 and 2019-12-31.

Monthly Sales

Chart

monthly_sales_by_model <- sales %>% 
  group_by(model) %>% 
  summarize_by_time(date, "month", sales = n())

write.csv(monthly_sales_by_model, "monthly_sales.csv", row.names = FALSE)
monthly_sales_by_model %>% 
  ungroup() %>% 
  plot_time_series(date, sales, .color_var = model, .smooth = FALSE, .interactive = FALSE,
                   .title = "Monthly Sales by Model",
                   .color_lab = "Model")

Data

reactable(monthly_sales_by_model,
          resizable = TRUE,
          filterable = TRUE,
          searchable = TRUE)

Anomalies

monthly_sales_by_model %>% 
  plot_anomaly_diagnostics(date, sales, .alpha = .25)

Profit

ggplot(sales, aes(x = model, y = net, color = model)) +
  geom_jitter(alpha = .25) +
  geom_point(stat = "summary", size = 5) +
  theme_minimal() +
  theme(legend.position = "none") +
  labs(title = "Profit by Model",
       x = "Model",
       y = "Profit")

New vs. returning customers

sales_by_returning <- sales %>% 
  group_by(returning, model) %>% 
  count()

sales_by_returning %>% 
  ggplot(aes(x = returning, y = n, fill = model)) +
  geom_bar(stat = "identity", position = "dodge") +
  theme_minimal() +
  labs(title = "Sales by Model and New vs. Returning Customer",
       x = "Returning customer?",
       y = "Sales",
       fill = "Model")